<template>
 <div class="login">
    <h2>校园超市</h2>
    <van-form @submit="onSubmit">
  <van-field
    v-model="phone"
    name="手机号"
    label="手机号"
    placeholder="请输入手机号"

  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
   
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" >登录</van-button>
  </div>
</van-form>
 </div>
</template>

<script>
import { mapActions } from 'vuex';
export default {
  data() {
    return {
      phone: '13412341236',
      password: 'abc123',
    };
  },
  // mounted(){
  //   this.getToken()
  // },  // 方法
  methods: {
    ...mapActions(['getToken','getMessage']),
    async onSubmit() {
      // debugger
      await this.getToken({phone:this.phone,password:this.password});
      await this.getMessage()
      this.$router.push('/layout/home')
    },
  },
};
</script>

<style lang='scss'>
.login{
  text-align: center;
}
</style>
